package cn.flying.cloud.flow.api.dubbo;

import javax.annotation.Resource;

import org.apache.dubbo.config.annotation.DubboService;

import cn.flying.cloud.flow.api.FlowServiceApi;
import cn.flying.cloud.flow.core.service.ProcessManageService;
import cn.flying.cloud.flow.model.FlowAuditVo;
import cn.flying.cloud.flow.model.FlowStartVo;

/**
 * 流程管理服务实现
 *
 * @author: admin
 * @date: 2025年05月12日 21:21
 * @version: 1.0
 */
@DubboService
public class FlowApiService implements FlowServiceApi {

    @Resource
    private ProcessManageService processManageService;

    /**
     * 流程启动
     *
     * @param process 参数对象
     * @return
     */
    @Override
    public String startProcess(FlowStartVo process) {
        return processManageService.startProcess(process);
    }

    /**
     * 流程撤回
     *
     * @param procInstId 流程实例ID
     */
    @Override
    public void cancelProcess(String procInstId) {
        processManageService.cancelProcess(procInstId);
    }

    /**
     * 删除撤回
     *
     * @param procInstId 流程实例ID
     * @param reason     删除原因
     */
    @Override
    public void deleteProcess(String procInstId, String reason) {
        processManageService.deleteProcess(procInstId, reason);
    }

    /**
     * 领取任务
     *
     * @param taskId   任务ID
     * @param assignee 用户ID
     */
    @Override
    public void claimTask(String taskId, String assignee) {
        processManageService.claimTask(taskId, assignee);
    }

    /**
     * 完成提交任务
     *
     * @param auditVo 任务对象
     */
    @Override
    public void completeTask(FlowAuditVo auditVo) {
        processManageService.completeTask(auditVo);
    }

    /**
     * 触发任务（争对Receive Task）
     *
     * @param processInstId 流程实例ID
     * @param activityId    节点ID
     */
    @Override
    public void triggerTask(String processInstId, String activityId) {
        processManageService.triggerTask(processInstId, activityId);
    }
}
